package com.babo72.android_test.xml;

import java.util.ArrayList;
import java.util.List;

public class ShopStickerInfo {

	private String pid;
	private String name;
	private String use_period;
	private String expire_date;
	private Type type;
	private String thumbnailurl;
	private String tabimageurl;
	private List<Sticker> stickers = new ArrayList<Sticker>();
	
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append("[" + this.getClass().getName() + "]\n")
				.append("\tpid:" + pid + "\n")
				.append("\tname:" + name + "\n")
				.append("\tuse_period:" + use_period + "\n")
				.append("\texpire_date:" + expire_date + "\n")
				.append("\ttype:" + type + "\n")
				.append("\tthumbnailurl:" + thumbnailurl + "\n")
				.append("\ttabimageurl:" + tabimageurl + "\n");
		for(int i = 0; i < stickers.size(); i++) {
			Sticker sticker = stickers.get(i);
			builder.append("\t\tSticker " + i + ":" + sticker);
		}
		return builder.toString();
	}

	public enum Type {
		ONE(1), SET(2);
		
		private int code;
		private Type(int c) {
			code = c;
		}
		public int getCode() {
			return code;
		}
	};
	

	public String getPid() {
		return pid;
	}
	public void setPid(String pid) {
		this.pid = pid;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getUse_period() {
		return use_period;
	}
	public void setUse_period(String use_period) {
		this.use_period = use_period;
	}
	public String getExpire_date() {
		return expire_date;
	}
	public void setExpire_date(String expire_date) {
		this.expire_date = expire_date;
	}
	public Type getType() {
		return type;
	}
	public void setType(Type type) {
		this.type = type;
	}
	public String getThumbnailurl() {
		return thumbnailurl;
	}
	public void setThumbnailurl(String thumbnailurl) {
		this.thumbnailurl = thumbnailurl;
	}
	public String getTabimageurl() {
		return tabimageurl;
	}
	public void setTabimageurl(String tabimageurl) {
		this.tabimageurl = tabimageurl;
	}
	public List<Sticker> getStickers() {
		return stickers;
	}
	public void addSticker(Sticker sticker) {
		if(stickers == null) {
			stickers = new ArrayList<Sticker>();
		}
		stickers.add(sticker);
	}
	
	public static class Sticker {
		private String sid;
		private String name;
		private String thumbnailurl;
		private int imagenum;
		private List<String> urls;
		
		public String toString() {
			StringBuilder builder = new StringBuilder();
			builder.append("\t[" + this.getClass().getName() + "]\n")
					.append("\t\tsid:" + sid + "\n")
					.append("\t\tname:" + name + "\n")
					.append("\t\tthumbnailurl:" + thumbnailurl + "\n")
					.append("\t\timagenum:" + imagenum + "\n");
			for(int i = 0; i < urls.size(); i++) {
				String url = urls.get(i);
				builder.append("\t\t\turl " + i + ":" + url + "\n");
			}
			return builder.toString();
		}
		
		public String getSid() {
			return sid;
		}
		public void setSid(String sid) {
			this.sid = sid;
		}
		public String getName() {
			return name;
		}
		public void setName(String name) {
			this.name = name;
		}
		public String getThumbnailurl() {
			return thumbnailurl;
		}
		public void setThumbnailurl(String thumbnailurl) {
			this.thumbnailurl = thumbnailurl;
		}
		public int getImagenum() {
			return imagenum;
		}
		public void setImagenum(int imagenum) {
			this.imagenum = imagenum;
		}
		public String getUrl(int idx) {
			return urls.get(idx);
		}
		public void addUrl(int idx, String url) {
			if(urls == null) {
				urls = new ArrayList<String>();
			}
			urls.add(idx, url);
		}
	}
}
